package com.atguigu.gmall.activity.controller;

import com.atguigu.gmall.activity.service.SeckillService;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author luYinLei
 * @version 1.0
 * @date 2021/7/15 10:36
 */
@RestController
@RequestMapping(value = "/seckill")
public class SeckillGoodsController {

    @Autowired
    private SeckillService seckillService;

    /**
     * 查询秒杀列表
     * @param time
     * @return
     */
    @GetMapping(value = "/list/{time}")
    public Result getSeckillGoods(@PathVariable(value = "time") String time){
        List<SeckillGoods> seckillGoods = seckillService.getSeckillGoods(time);
        return Result.ok(seckillGoods);
    }

    /**
     * 查询详情信息
     * @param time
     * @param id
     * @return
     */
    @GetMapping(value = "/details/{time}/{id}")
    public Result getSeckillGoodsDetails(@PathVariable(value = "time") String time,
                                         @PathVariable(value = "id") String id){
        SeckillGoods seckillGood = seckillService.getSeckillGoodsDetails(time, id);
        return Result.ok(seckillGood);
    }


}
